// RealPlay Ltd  copyrights.
// This program is Open Source AsIs
// You may use it for all purposes, including commercial
// But!!!
// If you use any part of this code, you must state clearly
// both in your source file and in the Help|about of your program,
// that the origin program or code was built by RealPlay Ltd

// ***********************************************************************/
// *                                                                     */
// *        This file is the Scale Dialog unit of "Paint" Program        */
// *                                                                     */
// ***********************************************************************/

unit UPScaleDlg;

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
  Buttons, ExtCtrls, Mask;

type
  TFScaleDlg = class(TForm)
    OKBtn: TButton;
    CancelBtn: TButton;
    Bevel1: TBevel;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    RadioButton4: TRadioButton;
    RadioButton5: TRadioButton;
    RadioButton6: TRadioButton;
    RadioButton7: TRadioButton;
    RadioButton8: TRadioButton;
    STe: TMaskEdit;
    StaticText1: TStaticText;
    RClear: TRadioButton;
    procedure Rclick(Sender: TObject);
    procedure STeKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure OKBtnClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    scale: integer;
  end;

var
  FScaleDlg: TFScaleDlg;

implementation

uses UPMain, UPUtil;
{$R *.dfm}

procedure TFScaleDlg.Rclick(Sender: TObject);

begin
  scale := TComponent(Sender).tag;
  if scale > 0 then
    STe.Text := inttostr(100 * scale)
  else
    STe.Text := inttostr(trunc(-100 / scale));

end;

procedure TFScaleDlg.STeKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  RClear.Checked := true;
end;

procedure TFScaleDlg.OKBtnClick(Sender: TObject);
begin
  scale := strtoint(STe.Text);
  with FPaint.FWA do
    if scale > 5 then
    begin
      ZoomXr :=scale/ 100 ;
      ZoomYr :=ZoomXr;
      ImPanel.Height := trunc(IM.Picture.Bitmap.Height * ZoomYr)
        + ImBottomPanel.Height;
      ImPanel.Width := trunc(IM.Picture.Bitmap.Width * ZoomXr) + IMRightPanel.Width;
      MyStat.Cx := ZoomXr;
      MyStat.Cy := ZoomYr;
      // FPaint.SoTool:=fToolSize;
    end;
end;

end.
